home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Source Code / C / Applications / Tcl-Tk 8.0 / Pre-installed version / tcl8.0 / generic / panic.c next >
Encoding:
C/C++ Source or Header  |  1997-08-15  |  2.3 KB  |  97 lines  |  [TEXT/CWIE]

  1. /* 
  2.  * panic.c --
  3.  *
  4.  *    Source code for the "panic" library procedure for Tcl;
  5.  *    individual applications will probably override this with
  6.  *    an application-specific panic procedure.
  7.  *
  8.  * Copyright (c) 1988-1993 The Regents of the University of California.
  9.  * Copyright (c) 1994 Sun Microsystems, Inc.
  10.  *
  11.  * See the file "license.terms" for information on usage and redistribution
  12.  * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
  13.  *
  14.  * SCCS: @(#) panic.c 1.15 96/09/12 14:55:25
  15.  */
  16.  
  17. #include <stdio.h>
  18. #ifdef NO_STDLIB_H
  19. #   include "../compat/stdlib.h"
  20. #else
  21. #   include <stdlib.h>
  22. #endif
  23.  
  24. #define panic panicDummy
  25. #include "tcl.h"
  26. #undef panic
  27.  
  28. EXTERN void        panic _ANSI_ARGS_((char *format, char *arg1,
  29.                 char *arg2, char *arg3, char *arg4, char *arg5,
  30.                 char *arg6, char *arg7, char *arg8));
  31.  
  32. /*
  33.  * The panicProc variable contains a pointer to an application
  34.  * specific panic procedure.
  35.  */
  36.  
  37. void (*panicProc) _ANSI_ARGS_(TCL_VARARGS(char *,format)) = NULL;
  38.  
  39. /*
  40.  *----------------------------------------------------------------------
  41.  *
  42.  * Tcl_SetPanicProc --
  43.  *
  44.  *    Replace the default panic behavior with the specified functiion.
  45.  *
  46.  * Results:
  47.  *    None.
  48.  *
  49.  * Side effects:
  50.  *    Sets the panicProc variable.
  51.  *
  52.  *----------------------------------------------------------------------
  53.  */
  54.  
  55. void
  56. Tcl_SetPanicProc(proc)
  57.     void (*proc) _ANSI_ARGS_(TCL_VARARGS(char *,format));
  58. {
  59.     panicProc = proc;
  60. }
  61.  
  62. /*
  63.  *----------------------------------------------------------------------
  64.  *
  65.  * panic --
  66.  *
  67.  *    Print an error message and kill the process.
  68.  *
  69.  * Results:
  70.  *    None.
  71.  *
  72.  * Side effects:
  73.  *    The process dies, entering the debugger if possible.
  74.  *
  75.  *----------------------------------------------------------------------
  76.  */
  77.  
  78.     /* VARARGS ARGSUSED */
  79. void
  80. panic(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8)
  81.     char *format;        /* Format string, suitable for passing to
  82.                  * fprintf. */
  83.     char *arg1, *arg2, *arg3;    /* Additional arguments (variable in number)
  84.                  * to pass to fprintf. */
  85.     char *arg4, *arg5, *arg6, *arg7, *arg8;
  86. {
  87.     if (panicProc != NULL) {
  88.     (void) (*panicProc)(format, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  89.     } else {
  90.     (void) fprintf(stderr, format, arg1, arg2, arg3, arg4, arg5, arg6,
  91.         arg7, arg8);
  92.     (void) fprintf(stderr, "\n");
  93.     (void) fflush(stderr);
  94.     abort();
  95.     }
  96. }
  97.